package thinkinjava4.ch12_exceptions;

public class WithFinally {
    private static Switch sw = new Switch();

    public static void main(String[] args) {
        try {
            sw.on();
            //假如这里抛出了异常off可以被执行
            OnOffSwitch.throwOtherException();
            OnOffSwitch.f();
        } catch (OnOffException2 | OnOffException1 e) {
            System.out.println(e.getClass().getSimpleName());
        } finally {
            sw.off();
        }
    }
}
